﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using S.RBAC.Api.Application.Command.RoleJurisdictionCommand;

namespace S.RBAC.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RoleJurisdictionController : ControllerBase
    {
        protected readonly IMediator _mediator;

        public RoleJurisdictionController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 添加权限分配
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> AddRoleJurisdiction(RoleJurisdictionCreateCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 删除权限分配
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<int> DelRoleJurisdiction([FromQuery]RoleJurisdictionDeleteCommand command)
        {
            return await _mediator.Send(command);
        }
    }
}
